/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mvc.ligasDeportivas;

import com.beans.UsuarioBean;
import com.mvc.RequestHandler;
import java.io.IOException;
import java.util.ArrayList;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author victor
 */
public class ListaLigas implements RequestHandler {

    public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, NamingException {
        String historica = (String) request.getParameter("historica");
        if(historica==null) historica="NO";
        System.out.println("Pasa");
        HttpSession sesion = request.getSession();
        ArrayList listaLigas;
        UsuarioBean usuario = (UsuarioBean) sesion.getAttribute("usuario");
        com.beans.ListaLigas lista = new com.beans.ListaLigas();
        if (historica.equalsIgnoreCase("SI")) {
            listaLigas = lista.ligasUsuario(true, usuario.getNick());
        } else {
            listaLigas = lista.ligasUsuario(false, usuario.getNick());
        }
        System.out.println("Fin");
        //Enviamos los valores a la pantalla (al jsp)
        request.setAttribute("lista", listaLigas);
        request.setAttribute("historica", historica);
    }
}
